package com.zmj.sy.mom.srv.aps.controller;

import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseIdReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseListResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BasePageResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.omb.*;
import com.zmj.sy.mom.srv.aps.service.OrderMaterialBorrowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequiredArgsConstructor
@Api(tags = "订单借料")
@RestController
@RequestMapping("/orderMaterialBorrow")
public class OrderMaterialBorrowController {

    private final OrderMaterialBorrowService orderMaterialBorrowService;

    @ApiOperation("订单借料-左侧树")
    @GetMapping("/tree")
    public BaseListResVo<OrderMaterialBorrowTreeResVo> tree(OrderMaterialBorrowTreeReqVo reqVo) {
        List<OrderMaterialBorrowTreeResVo> resList = orderMaterialBorrowService.tree(reqVo);
        return new BaseListResVo<>(resList);
    }

    @ApiOperation("订单借料-右侧借料列表")
    @GetMapping("/list")
    public BasePageResVo<OrderMaterialBorrowListResVo> list(OrderMaterialBorrowListReqVo reqVo) {
        return orderMaterialBorrowService.list(reqVo);
    }

    @ApiOperation("订单借料-新增借料")
    @PostMapping("/add")
    public BaseResVo add(@RequestBody OrderMaterialBorrowAddReqVo reqVo) {
        orderMaterialBorrowService.add(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("订单借料-修改借料")
    @PostMapping("/edit")
    public BaseResVo edit(@RequestBody OrderMaterialBorrowEditReqVo reqVo) {
        orderMaterialBorrowService.edit(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("订单借料-删除借料")
    @PostMapping("/delete")
    public BaseResVo delete(@RequestBody BaseIdReqVo reqVo) {
        orderMaterialBorrowService.delete(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("订单借料-施工号列表")
    @GetMapping("/consList")
    public BasePageResVo<OrderMaterialBorrowConsListResVo> consList(OrderMaterialBorrowConsListReqVo reqVo) {
        return orderMaterialBorrowService.consList(reqVo);
    }

    @ApiOperation("订单借料-新增施工号")
    @PostMapping("/consAdd")
    public BaseResVo consAdd(@RequestBody OrderMaterialBorrowConsAddReqVo reqVo) {
        orderMaterialBorrowService.consAdd(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("订单借料-修改施工号")
    @PostMapping("/consEdit")
    public BaseResVo consEdit(@RequestBody OrderMaterialBorrowConsEditReqVo reqVo) {
        orderMaterialBorrowService.consEdit(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("订单借料-删除施工号")
    @PostMapping("/consDelete")
    public BaseResVo consDelete(@RequestBody BaseIdReqVo reqVo) {
        orderMaterialBorrowService.consDelete(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("订单借料-零件列表")
    @GetMapping("/partList")
    public BasePageResVo<OrderMaterialBorrowPartListResVo> partList(OrderMaterialBorrowPartListReqVo reqVo) {
        return orderMaterialBorrowService.partList(reqVo);
    }

    @ApiOperation("订单借料-零件日志")
    @GetMapping("/partLog")
    public BasePageResVo<OrderMaterialBorrowPartLogResVo> partLog(OrderMaterialBorrowPartLogReqVo reqVo) {
        return orderMaterialBorrowService.partLog(reqVo);
    }
}
